{template 'common/header'}
	<ul class="nav nav-tabs">
        <li class="active" ><a href="{php echo $this->createWebUrl('fansinfo',array('op' => 'display'))}">参与用户管理</a></li>
		<!-- <li><a href="./index.php?c=platform&a=reply&do=post&m={php echo $this->modulename}">添加活动</a></li> -->
	</ul>
    <style>
    th{
        text-align: center !important;
    }
    td{
        text-align: center !important;
        white-space: normal !important;
        word-break: break-all !important;
    }
    td.div{
        text-align: center !important;
        white-space: normal !important;
        word-break: break-all !important;
    }
    </style>
<!--  -->

{if $op == 'display'}
<div class="main">
    <div class="panel panel-default">
        <div class="panel-heading">
            活动概览
        </div>
        <div class="panel-body">
            <div class="alert" style="margin-bottom:0;">
                <span  class="btn btn-warning btn-sm">参与人数：{$total} </span>
                <!-- <a href="{php echo $this->createWebUrl('export',array('rid'=>$rid))}" class="btn btn-primary btn-sm">导出用户数据</a> -->
            </div>
        </div>
    </div>
    <div style="padding:15px;background: white;">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th>微信头像</th>
                    <th>Openid</th>
                    <th>游戏分数</th>
                    <!-- <th>活动码</th> -->
                    <!-- <th>手机号码</th>
                    <th>获取时间</th>
                    <th>最后更新时间</th> -->
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $l}
                <tr>
                    <td><img src="{$l['avatar']}" style="width: 50px;height: 50px;"><br>{$l['nickname']}</td>
                    <td>{$l['openid']}</td>
                    <!-- <td>{$l['max_score']}</td> -->
                    <td><input style="width: 70px;display: inline-block;" type="text" name="max_score" min="0" class="form-control" value="{$l['max_score']}"></td>
                    <!-- <td>{$l['mobile']}</td>
                    <td>{$l['usertime']}</td>
                    <td>{$l['lasttime']}</td>   -->                                 
                    <td>
                        <a class="btn btn-success btn-sm" onclick="onSave(this,{$l['id']})">确认修改</a>
                        <!-- <a onclick="return confirm('修改后数据将改变粉丝排名，确定修改吗？')" href='{php echo $this->createWebUrl("fansinfo",array("op"=>"update","id"=>$l["id"],"max_score"=>$l["max_score"]))}' class="btn btn-success btn-sm">确认修改</a> -->
                        <a onclick="return confirm('删除后数据将不可恢复，确定删除吗？')" href='{php echo $this->createWebUrl("fansinfo",array("op"=>"delete","id"=>$l["id"]))}' class="btn btn-danger btn-sm">删除</a>
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>

<script>

function onSave(obj,id){
    var tr = $(obj).parent().parent();

    var max_score = tr.find('input[name="max_score"]').val();
    
    $.ajax({

        url:'{php echo $this->createWebUrl("fansinfo", array("op"=>"update"))}',

        type:'post',

        data:{id:id,max_score:max_score},

        success: function(msg){

            if(msg == '1'){

                alert('修改分数成功！');

            }else{

                alert('修改数据失败!');

            }
            location.reload();
        },

        error: function(){

            alert('发送请求失败，请重试!');

            location.reload();

        }

    });

}

</script>

{/if}
{template 'common/footer'}